package com.msc.cili.service.user.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.msc.cili.common.utils.BdUtil;
import com.msc.cili.repository.dao.user.UserMapper;
import com.msc.cili.repository.entity.user.User;
import com.msc.cili.service.user.UserService;
import com.msc.cili.service.user.bo.UserInfoBo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Resource
    private UserMapper userMapper;


    @Override
    public List<UserInfoBo> getUserInfoList() {
        List<User> userInfo = userMapper.getUserInfo();
        List<UserInfoBo> userInfoBos = BdUtil.do2bo4List(userInfo, UserInfoBo.class);
        return userInfoBos;
    }

    @Override
    public UserInfoBo getUserInfoByUserName(String userName) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(User::getUsername, userName);
        User userInfo = this.getOne(queryWrapper);
        UserInfoBo userInfoBo = BdUtil.do2bo(userInfo, UserInfoBo.class);
        return userInfoBo;
    }
}
